
import { defineStore } from 'pinia';
import { getProductNameApi } from '@/api/index'
export const useUtiStore = defineStore('uti', {
    persist: {
        storage: localStorage,
    },
    state: () => {
        return {
            paymentInfo:{ 
                // "paymentMethodId": "pm_1RAjeG4hjKHAJxYpyeIL1HoU",
                // "firstName": "Kitty",
                // "lastName": "Johnson",
                // "dateOfBirth": "01/02/2025",
                // "billingName": "Kitty Johnson",
                // "billingAddr1": "123 Main St.",
                // "billingAddr2": "billingAddr2",
                // "billingCity": "billingCity",
                // "billingState": "AL",
                // "billingZipCode": "60007",
                // "shippingName": "Kitty Johnson",
                // "shippingAddr1": "shippingAddr1",
                // "shippingAddr2": "shippingAddr2",
                // "shippingCity": "shippingCity",
                // "shippingState": "IL",
                
                // "shippingZipCode": "60008",
                // "email": "sara@doe.com",
                // "phone": "1234567890",
                // "insurer": "unitedhealthcare",
                // "insuredMemberId": "5678",
                // "cardholder": "Joe Doe",
                // "productId": "Complete Kit",
                // "shippingCountry": "USA", 
                // "productPrice": 199.0,
                // "shippingCost": 28.99,
                // "labCost": 0, 
                // "chargeShipping": "Y",
                // "useShippingAddr": "Y",
                // "qInsurerResponse": "Ambetter",
                // "shipping": '', //是否邮寄 TRUE | FALSE
                // "tax": '',
                // 'orderId': ''


                "paymentMethodId": "", 
                "firstName": "", 
                "lastName": "", 
                "dateOfBirth": "", 
                "billingName": "", 
                "billingAddr1": "", 
                "billingAddr2": "", 
                "billingCity": "", 
                "billingState": "", 
                "billingZipCode": "",
                "billingCountry": "USA", 
                "shippingName": "", 
                "shippingAddr1": "", 
                "shippingAddr2": "", 
                "shippingCity": "", 
                "shippingState": "", 
                "shippingCountry": "USA", 
                "shippingZipCode": "", 
                "email": "",    
                "phone": "", 
                "insurer": "", 
                "insuredMemberId": "", 
                "cardholder": "", 
                "labCost": 0, 
                "shippingCost": null,    
                "chargeShipping": "N",    
                "useShippingAddr": "N",  // 使用shipping邮寄地址
                "qInsurerResponse": "",
                "productId": '', // MyUTI_complete 或 MyUTI_lab_test 
                "productPrice": 0, //  产品价格 === labCost
                "shipping": '', //是否邮寄 TRUE | FALSE
                "tax": '',
                "orderId": '',
                "productName": ''
            },
            selectedOption: '-1',
            lastCastFour: '',
            order: '',
        };
    },
    getters: {
        productName(state){
            return state.paymentInfo.productName
            
            // state.paymentInfo.productId
            // if(state.paymentInfo.productId === 'MyUTI_complete'){
            //     const res = await getProductNameApi('MyUTI_complete')
            //     return 'MyUTI Complete Test Kit'
            // }else if(state.paymentInfo.productId === 'MyUTI_lab_test'){
            //     return 'MyUTI Lab Test'
            // }
        },
        orderbackLink(state){
            if(state.paymentInfo.productId === 'MyUTI_complete'){
                return 'https://www.myuti.com/complete-home-test-kit'
            }else if(state.paymentInfo.productId === 'MyUTI_lab_test'){
                return 'https://www.myuti.com/lab-test'
            }
        }
    },
    actions: {
        setItemPaymentInfoValue(itemKey,itemValue) {
            this.paymentInfo[itemKey] = itemValue;
        },
        // setInsuranceFontValue(Value) {
        //     this.cardImageFront = Value;
        // },
        // setInsuranceBackValue(Value) {
        //     this.cardImageBack = Value;
        // },
        setProductName(Value) {
            this.productName = Value;
        },
        setPrice(Value) {
            this.price = Value;
        },
        setIsSend(Value) {
            this.isSend = Value;
        },
    }
});